﻿using System;
using IPCChannel;
using UProveAPI;

namespace Prover
{
    public class Program
    {
        static void Main(string[] args)
        {
            string issuerIp = "127.0.0.1";
            int issuerPort = 8060;
            string verifierIp = "127.0.0.1";          
            int verifierPort = 8080;

            Console.WriteLine("Press [ENTER] to exit.\n");

            IIPCClient ipcClient = new UProveTCPClient("127.0.0.1", 8070);
            UProveAPI.Prover prover = new UProveAPI.Prover(ipcClient);

            byte[][] attributes = new byte[][] {
                ipcClient.Encoding().GetBytes("my first name"),
                ipcClient.Encoding().GetBytes("my last name"),
                ipcClient.Encoding().GetBytes("my email address") };

            prover.TokensReceived += tokens =>
                {
                    prover.PresentToken(verifierIp, verifierPort, tokens[0], new int[] { 2 });
                };

            prover.RequestTokens(issuerIp, issuerPort, attributes, 1);
           
            Console.ReadKey();
            ipcClient.Dispose();
        }
    }
}
